{include file="public/header" /}
{load href="__PLUGINS__iCheck/icheck.min.js"}
{load href="__PLUGINS__iCheck/custom.css"}
<!-- 加载编辑器的容器 -->
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <form class="form-horizontal" method="post" enctype="multipart/form-data">
            <div class="col-sm-12">
                <div class="tabs-container">
                    <div class="tab-content">
                        <div class="ibox-content">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">类型：</label>
                                <div class="col-sm-9">
                                    <select class="form-control" id="group_id" name="group_id">
                                        <option value="1" {present name="name"}{if condition="$name.group_id == 1"}selected="selected"{/if}{else /}selected="selected"{/present}>积分记录</option>
                                        <option value="2" {present name="name"}{if condition="$name.group_id == 2"}selected="selected"{/if}{/present}>金币记录</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group" id="coverDiv">
                                <label class="col-sm-2 control-label">文件：</label>
                                <div class="col-sm-9">
                                    <input id="file" name="file" type="file" class="form-control">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
{include file="public/footer" /}

<style type="text/css">
.tbutton{ 
  position: fixed;
  bottom:0px;
  width: 100%;
  background: #fff;
  padding-top: 20px;
  padding-bottom: 20px;
  border-top: 1px solid #F5EFEF;
  z-index: 99999999999
}
#button{ width:120px; margin: 0 auto;}
</style>
<div class="tbutton">
  <div id="button"><button class="btn btn-w-m btn-primary" type="button"><i class="fa fa-check"></i> &nbsp;{present name="name"}修改{else /}提交{/present}</button></div>
</div>

<script type="text/javascript">

    $("#button").click(function(){

        var fileobj = $("#file")[0].files[0];
        console.log(fileobj);
        var form = new FormData();
        form.append("file", fileobj);
        form.append("group_id", $('#group_id').val());


        $.ajax({
            type: 'POST',
            url: '',
            data: form,
            processData: false,
            contentType: false,
            success: function (ret) {
                if(ret){
                    if(ret.ret){
                        swal_msg(ret.ret,'',"success",-1)
                    }else{
                        layer.msg(ret.err)
                    }
                }else{
                    swal_msg("错误",ret,"error");
                }
            }
        })
    })

</script>